<h2>Runtime images</h2>

<p>
    A runtime image of your JavaFX project is a custom JRE that contains only the platform modules that are required for your application.
</p>

<p>
    If you want to create a runtime image of your JavaFX project follow these instructions.
</p>

<p>
    Download an appropriate <a target="_blank" href="https://gluonhq.com/products/javafx/">JavaFX runtime and JavaFX jmods</a>
    for your operating system and unzip them to a desired location.
</p>

<p>
    Add these environment variables pointing to the lib directory of the runtime and to the jmods directory:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-mods" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-mods" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-mods">
<pre class="no-border-radius"><code>
export PATH_TO_FX=path/to/javafx-sdk-<span class="JFX_VERSION">12</span>/lib
export PATH_TO_FX_MODS=path/to/javafx-jmods-<span class="JFX_VERSION">11</span>
</code></pre>
    </div>
    <div class="tab-pane" id="win-mods">
<pre><code>
set PATH_TO_FX="path\to\javafx-sdk-<span class="JFX_VERSION">12</span>\lib"
set PATH_TO_FX_MODS="path\to\javafx-jmods-<span class="JFX_VERSION">11</span>"
</code></pre>
    </div>
</div>

<div id="MOD-CLI"></div><h3>Command Line</h3>

<p>
    You can run or create a runtime image of your JavaFX project from command line. A simple example can be found in this 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/CLI" target="_blank">project</a>.
</p>

<p>
    The application has a single class <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/CLI/hellofx/src/hellofx/HelloFX.java" target="_blank">HelloFX.java</a> with its 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/CLI/hellofx/src/module-info.java" target="_blank">module-info</a> 
    file that defines the <kbd>hellofx</kbd> module.
    
    Compile it either using the JavaFX SDK:
</p>
    
<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-javacd" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-javacd" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-javacd">
<pre class="no-border-radius"><code>
javac --module-path $PATH_TO_FX -d mods/hellofx $(find src/ -name "*.java")
</code></pre>
    </div>
    <div class="tab-pane" id="win-javacd">
<pre><code>
dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/hellofx @sources.txt & del sources.txt
</code></pre>
    </div>
</div>

<p>
    or using the JavaFX jmods:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-javacdmod" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-javacdmod" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-javacdmod">
<pre class="no-border-radius"><code>
javac --module-path $PATH_TO_FX_MODS -d mods/hellofx $(find src/ -name "*.java")
</code></pre>
    </div>
    <div class="tab-pane" id="win-javacdmod">
<pre><code>
dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX_MODS% -d mods/hellofx @sources.txt & del sources.txt
</code></pre>
    </div>
</div>

<div class="alert alert-warning">
    <strong>Note: </strong>
    Note that the output is placed under <kbd>mods/hellofx</kbd> for convenience, but it could use any other name.
</div>

<p>
    To run the modular application with the <kbd>java</kbd> command you need the JavaFX SDK modules and your module
    added to the module path:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-javamod" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-javamod" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-javamod">
<pre class="no-border-radius"><code>
java --module-path $PATH_TO_FX:mods -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
    <div class="tab-pane" id="win-javamod">
<pre><code>
java --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
</div>

<a class="jlink"></a><h4>jlink</h4>

<p>
    With a modular project, <a href="https://docs.oracle.com/en/java/javase/15/docs/specs/man/jlink.html" target="_blank">jlink</a>
    can be used to create a custom runtime image using the JavaFX jmods:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jlink" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jlink" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-jlink">
<pre class="no-border-radius"><code>
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods --add-modules hellofx --output hellofx
</code></pre>
    </div>
    <div class="tab-pane" id="win-jlink">
<pre><code>
jlink --module-path "%PATH_TO_FX_MODS%;mods" --add-modules hellofx --output hellofx
</code></pre>
    </div>
</div>

<p>
    And after the image is built, you can run it:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-run" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-run" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-run">
<pre class="no-border-radius"><code>
hellofx/bin/java -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
    <div class="tab-pane" id="win-run">
<pre><code>
hellofx\bin\java -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
</div>

<div class="alert alert-warning">
    <strong>Note: </strong>
    This custom JRE is platform-specific.
</div>

<div id="MOD-Maven"></div><h3>Maven</h3>

<p>
    You can run or create a runtime of your JavaFX Maven project. A simple example can be found in this  
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Maven" target="_blank">project</a>.
</p>

<p>
    The application has a main class <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Maven/hellofx/src/main/java/org/openjfx/MainApp.java" target="_blank">MainApp.java</a> with its 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Maven/hellofx/src/main/java/module-info.java" target="_blank">module-info</a> 
    file that defines the <kbd>hellofx</kbd> module. It also uses FXML, and requires the <kbd>javafx.fxml</kbd> dependency added to
    the <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Maven/hellofx/pom.xml" target="_blank">pom.xml</a>.
</p>

<p>
    It can be compiled and run on command line with <kbd>javac</kbd>, but using Maven we can simply do:
</p>

<pre><code>
mvn clean javafx:run
</code></pre>

<p>
    To create a custom runtime, using the <a href="https://github.com/openjfx/javafx-maven-plugin" target="_blank">JavaFX Maven plugin</a>, you can do:
</p>

<pre><code>
mvn clean javafx:jlink
</code></pre>

<p>
    Note the plugin allows the usual <a href="https://github.com/openjfx/javafx-maven-plugin#javafxjlink-options" target="_blank">options</a> as the <kbd>jlink</kbd> command, as well as creating a
    launcher or a zip with the custom image.
</p>

<p>
    And after the image is built, you can run it from command line:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-mvn-run" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-mvn-run" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-mvn-run">
<pre class="no-border-radius"><code>
target/hellofx/bin/launcher
</code></pre>
    </div>
    <div class="tab-pane" id="win-mvn-run">
<pre><code>
target\hellofx\bin\launcher
</code></pre>
    </div>
</div>

<div id="MOD-Gradle"></div><h3>Gradle</h3>

<p>
    You can run or create a runtime of your JavaFX Gradle project. A simple example can be found in this 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Gradle" target="_blank">project</a>.
</p>

<p>
    The application has a main class <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Gradle/hellofx/src/main/java/hellofx/HelloFX.java" target="_blank">HelloFX.java</a> with its 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Gradle/hellofx/src/main/java/module-info.java" target="_blank">module-info</a> 
    file that defines the <kbd>hellofx</kbd> module, and the required 
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Modular/Gradle/hellofx/build.gradle" target="_blank">build.gradle</a> file.
</p>

<p>
    It can be compiled and run on command line with <kbd>javac</kbd>, but using Gradle we can simply do:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-cligradlerun" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-cligradlerun" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-cligradlerun">
<pre class="no-border-radius"><code>
./gradlew run
</code></pre>
    </div>
    <div class="tab-pane" id="win-cligradlerun">
<pre><code>
gradlew run
</code></pre>
    </div>
</div>

<p>
    To create a custom runtime the referred <a class="modular-jlink-action" href="#">steps</a> can be used to generate a gradle task.
    Alternatively, there is a plugin that does it for us: the <a href="https://badass-jlink-plugin.beryx.org/releases/latest/" target="_blank">org.beryx.jlink</a>.
    It can be combined with the JavaFX Gradle plugin:
</p>

<pre><code>
plugins {
  id 'application'
  id 'org.openjfx.javafxplugin' version '<span class="JFX_PLUGIN_VERSION">0.0.7</span>'
  id 'org.beryx.jlink' version '<span class="JLINK_PLUGIN_VERSION">2.9.4</span>'
}

javafx {
    version = "<span class="JFX_VERSION">12</span>"
    modules = [ 'javafx.controls' ]
}

jlink {
    launcher {
        name = 'hellofx'
    }
}
</code></pre>

<p>
    to generate and run the custom image:
</p>
<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-cligradlelink" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-cligradlelink" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-cligradlelink">
<pre class="no-border-radius"><code>
./gradlew jlink
build/image/bin/hellofx
</code></pre>
    </div>
    <div class="tab-pane" id="win-cligradlelink">
<pre><code>
gradlew jlink
build\image\bin\hellofx
</code></pre>
    </div>
</div>

<div id="JDK-FX"></div><h3>Custom JDK+JavaFX image</h3>

<p>
    You can use <kbd>jlink</kbd> to create a runtime image that includes some or all the JavaFX modules, 
    without being attached to a given project. 
</p>

<p>
    With this image you will be able to run JavaFX modular or non-modular projects, use it as a new JRE from your
    IDE to create regular JavaFX projects, or even use its <kbd>jlink</kbd> command to create a new 
    custom image for your project.
</p>

<p>
    For instance, you can create an image that contains the <kbd>java.se</kbd> 
    <a href="https://docs.oracle.com/en/java/javase/15/docs/api/java.se/module-summary.html" target="_blank">module</a> and the JavaFX modules,
    by running:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jdkfx" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jdkfx" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-jdkfx">
<pre class="no-border-radius"><code>
export PATH_TO_FX_MODS=path/to/javafx-jmods-<span class="JFX_VERSION">11</span>
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS \
    --add-modules java.se,javafx.fxml,javafx.web,javafx.media,javafx.swing \
    --bind-services --output /path/to/jdkfx-<span class="JFX_VERSION">11</span>.jdk
</code></pre>
    </div>
    <div class="tab-pane" id="win-jdkfx">
<pre><code>
set PATH_TO_FX_MODS="path\to\javafx-jmods-<span class="JFX_VERSION">11</span>"
%JAVA_HOME%\bin\jlink --module-path %PATH_TO_FX_MODS% \
    --add-modules java.se,javafx.fxml,javafx.web,javafx.media,javafx.swing \
    --bind-services --output \path\to\jdkfx-<span class="JFX_VERSION">11</span>
</code></pre>
    </div>
</div>

<h4>Use custom image</h4>

<p>
    With this custom image, you can set a new <kbd>JAVA_HOME</kbd>:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jdkfx-home" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jdkfx-home" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-jdkfx-home">
<pre class="no-border-radius"><code>
export JAVA_HOME=/path/to/jdkfx-<span class="JFX_VERSION">11</span>.jdk
</code></pre>
    </div>
    <div class="tab-pane" id="win-jdkfx-home">
<pre><code>
set JAVA_HOME="path\to\jdkfx-<span class="JFX_VERSION">11</span>"
</code></pre>
    </div>
</div>

<p>
    Since the JavaFX modules are already part of the runtime, now you can run the HelloFX <a href="" target="_blank">sample</a> 
    without the need of adding <kbd>PATH_TO_FX</kbd> anymore, like:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jdkfx-run" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jdkfx-run" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-jdkfx-run">
<pre class="no-border-radius"><code>
javac -d mods/hellofx $(find src/ -name "*.java")
java --module-path mods -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
    <div class="tab-pane" id="win-jdkfx-run">
<pre><code>
dir /s /b src\*.java > sources.txt & javac -d mods/hellofx @sources.txt & del sources.txt
java --module-path mods -m hellofx/hellofx.HelloFX
</code></pre>
    </div>
</div>

<p>
    Or add the image to your IDE:

    <a href="images/modular/netbeans01.png" target="_blank"><img src="images/modular/netbeans01.png" alt="Adding JDK+FX platform"/></a>
    
    And start creating Java projects with JavaFX classes.
    
    <a href="images/modular/netbeans02.png" target="_blank"><img src="images/modular/netbeans02.png" alt="Create JavaFX project"/></a>
    
    And run them without any additional option:
    
    <a href="images/modular/netbeans03.png" target="_blank"><img src="images/modular/netbeans03.png" alt="Run JavaFX project"/></a>
</p>

<div class="alert alert-warning">
    <strong>Note: </strong>
    This custom JRE is platform-specific and it is not intended for distribution, and if there is a new JDK or a new 
    JavaFX SDK, it has to be created all over again. However, its <kbd>jlink</kbd> tool can be used to create a custom
    image with the project that can be distributed.
    And the <kbd><a href="https://docs.oracle.com/en/java/javase/15/docs/specs/man/jpackage.html" target="_blank">jpackage tool</a></kbd> can
    be used for distributing installers with the jlinked project.
</div>

<div id="Non-Mod"></div><h3>Non-modular application</h3>

<p>
    Since Java 9, applications should be modular, and distributed with tools like <a href="index.html#modular">jlink</a>.
    However, if you have a non-modular JavaFX project or you can't use <kbd>jlink</kbd> because you
    have non-modular dependencies where the automatic module naming convention doesn't apply, you can still create a fat jar.
</p>

<p>
    As explained <a href="http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-June/021977.html" target="_blank">here</a>,
    in order to create a runnable jar with all the required JavaFX dependencies, 
    you will need to use a launcher class that doesn't extend from <kbd>Application</kbd>.
</p>

<h4>Maven</h4>

<p>
    If you develop your JavaFX applications using Maven, you don't have to download
    the JavaFX SDK. Just specify the modules and the versions you want in the <kbd>pom.xml</kbd> file,
    and the build system will download the required modules, including the native libraries 
    for your platform.
</p>
<p>
    A simple Maven example can be found in this  
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Non-modular/Maven" target="_blank">project</a>.
    The <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Non-modular/Maven/hellofx/pom.xml" target="_blank">pom.xml</a> 
    file shows how to create a runnable fat jar for this <kbd>hellofx</kbd> project with the Maven shade plugin.
</p>

<p>
    Run the plugin to create the fat jar:
</p>

<pre><code>
mvn compile package
</code></pre>

<p>
    Run the application using:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-maven" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-maven" data-toggle="tab">Windows</a>
    </li>
</ul>
<div class="tab-content">
    <div class="tab-pane active" id="nix-maven">
<pre class="no-border-radius"><code>
java -jar shade/hellofx.jar
</code></pre>
    </div>
    <div class="tab-pane" id="win-maven">
<pre><code>
java -jar shade\hellofx.jar
</code></pre>
    </div>
</div>

<h5>Cross-platform jar</h5>

<p>
    You can create a cross-platform fat jar by adding the dependencies from the 
    three platforms that require native libraries to your pom file, in this sample 
    only the ones from <kbd>javafx.graphics</kbd>:
</p>

<pre><code>
    &lt;dependencies&gt;
        ...
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-graphics&lt;/artifactId&gt;
            &lt;version&gt;<span class="JFX_VERSION">12</span>&lt;/version&gt;
            &lt;classifier&gt;win&lt;/classifier&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-graphics&lt;/artifactId&gt;
            &lt;version&gt;<span class="JFX_VERSION">12</span>&lt;/version&gt;
            &lt;classifier&gt;linux&lt;/classifier&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-graphics&lt;/artifactId&gt;
            &lt;version&gt;<span class="JFX_VERSION">12</span>&lt;/version&gt;
            &lt;classifier&gt;mac&lt;/classifier&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
</code></pre>

<h4>Gradle</h4>

<p>
    If you develop your JavaFX applications using Gradle, you don't have to download
    the JavaFX SDK. Just specify the modules and the versions you want in the <kbd>build.gradle</kbd> file,
    and the build system will download the required modules, 
    including the native libraries for your platform. However, for Gradle we need to 
    find and specify the platform/OS as classifier.
</p>

<p>
    A simple Gradle example can be found in this  
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Non-modular/Gradle" target="_blank">project</a>.
    In order to create a runnable fat jar for this project with Gradle,
    modify the <kbd>jar</kbd> task in the <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Non-modular/Gradle/hellofx/build.gradle" target="_blank">build</a> 
    file to include the launcher class:
</p>

<pre><code>
mainClassName = 'hellofx.HelloFX'
jar {
    manifest {
        attributes 'Main-Class': 'hellofx.Launcher'
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}
</code></pre>

<p>
    Now run the task to create the fat jar and run it:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-gradle" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-gradle" data-toggle="tab">Windows</a>
    </li>
</ul>
<div class="tab-content">
    <div class="tab-pane active" id="nix-gradle">
<pre class="no-border-radius"><code>
./gradlew jar

java -jar build/libs/hellofx.jar
</code></pre>
    </div>
    <div class="tab-pane" id="win-gradle">
<pre><code>
gradlew.bat jar

java -jar build\libs\hellofx.jar
</code></pre>
    </div>
</div>

<h5>Cross-platform jar</h5>

<p>
    You can create a cross-platform fat jar by adding the dependencies from the 
    three platforms that require native libraries to the build file, in this sample 
    only the ones from <kbd>javafx.graphics</kbd>:
</p>

<pre><code>
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:win"
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:linux"
runtimeOnly "org.openjfx:javafx-graphics:$javafx.version:mac"
</code></pre>

<p>
    Now run the jar task again to create the cross-platform fat jar.
</p>

<a name="command-line"></a><h3>Command Line</h3>

<p>
    Finally, you can also create a runnable fat jar for your JavaFX project on command line.
</p>

<div class="alert alert-danger">
    <strong>Warning</strong>: This is a discouraged tedious error-prone manual process 
    that should be avoided by using the <a href="#Maven" class="alert-danger">Maven</a>'s shade plugin or 
    the <a href="#Gradle" class="alert-danger">Gradle</a>'s jar task, in case <a href="index.html#modular" class="alert-danger">jlink</a>
    is not applicable.
</div>

<p>
    An example can be found in this  
    <a class="samples" href="https://github.com/openjfx/samples/blob/master/CommandLine/Non-modular/CLI" target="_blank">project</a>.
    
    Download the appropriate
    <a target="_blank" href="https://gluonhq.com/products/javafx/">JavaFX SDK</a>
    for your operating system and unzip it to a desired location.
</p>

<p>
    Add an environment variable pointing to the lib directory of the runtime:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-fxpath" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-fxpath" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-fxpath">
<pre class="no-border-radius"><code>
export PATH_TO_FX=/path/to/javafx-sdk-<span class="JFX_VERSION">11</span>/lib
</code></pre>
    </div>
    <div class="tab-pane" id="win-fxpath">
<pre><code>
set PATH_TO_FX="path\to\javafx-sdk-<span class="JFX_VERSION">11</span>\lib"
</code></pre>
    </div>
</div>

<p>
    Compile the project:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-javacout" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-javacout" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-javacout">
<pre class="no-border-radius"><code>
javac --module-path $PATH_TO_FX --add-modules=javafx.controls -d out $(find src/main/java -name "*.java")
</code></pre>
    </div>
    <div class="tab-pane" id="win-javacout">
<pre><code>
dir /s /b src\main\java\*.java > sources.txt & javac --module-path %PATH_TO_FX% --add-modules=javafx.controls -d out @sources.txt & del sources.txt
</code></pre>
    </div>
</div>

<p>
    And create the fat jar, adding the JavaFX required jars and the platform-specific native libraries. For 
    the <kbd>hellofx</kbd> project:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jar" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jar" data-toggle="tab">Windows</a>
    </li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="nix-jar">
<pre class="no-border-radius"><code>
find $PATH_TO_FX/{javafx.base.jar,javafx.graphics.jar,javafx.controls.jar} -exec unzip -nq {} -d out \;

#uncomment for Linux:
#cp $PATH_TO_FX/{libprism*.so,libjavafx*.so,libglass*.so,libdecora_sse.so} out

#uncomment for Mac:
#cp $PATH_TO_FX/{libprism*.dylib,libjavafx*.dylib,libglass.dylib,libdecora_sse.dylib} out

rm out/META-INF/MANIFEST.MF out/module-info.class
mkdir libs
jar --create --file=libs/hellofx.jar --main-class=hellofx.Launcher -C out .
</code></pre>
    </div>
    <div class="tab-pane" id="win-jar">
<pre><code>
cd out & jar xf "%PATH_TO_FX%\javafx.base.jar" & jar xf "%PATH_TO_FX%\javafx.graphics.jar" & jar xf "%PATH_TO_FX%\javafx.controls.jar" & cd ..
copy "%PATH_TO_FX%\..\bin\prism*.dll" out & copy "%PATH_TO_FX%\..\bin\javafx*.dll" out & copy "%PATH_TO_FX%\..\bin\glass.dll" out && copy "%PATH_TO_FX%\..\bin\decora_sse.dll" out
del out\META-INF\MANIFEST.MF & del out\module-info.class
mkdir libs
jar --create --file=libs/hellofx.jar --main-class=hellofx.Launcher -C out .
</code></pre>
    </div>
</div>

<p>
    And after the jar is built, you can run it:
</p>

<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" href="#nix-jarrun" data-toggle="tab">Linux/Mac</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="#win-jarrun" data-toggle="tab">Windows</a>
    </li>
</ul>
<div class="tab-content">
    <div class="tab-pane active" id="nix-jarrun">
<pre class="no-border-radius"><code>
java -jar libs/hellofx.jar
</code></pre>
    </div>
    <div class="tab-pane" id="win-jarrun">
<pre><code>
java -jar libs\hellofx.jar
</code></pre>
    </div>
</div>

<div class="alert alert-warning">
    <strong>Note: </strong>
    This JRE is platform-specific. However it can be easily a multi-platform jar if the
    different native libraries from each platform were included. This requires downloading the JavaFX SDKs
    for all the platforms, extracting all the necessary jars (for instance, <kbd>javafx.graphics</kbd> is 
    different for each platform), and copying all the native libraries as shown above. As it was mentioned 
    above, this process shouldn't be done manually.
</div>

